#include "LoadGameState.h"

#include "Game.h"
#include "MainMenuState.h"
#include "GamePlayState.h"
#include "SGD Wrappers/CSGD_XAudio2.h"


LoadGameState::LoadGameState(void)
{
	// Set data members to 'clean' default values
	D3D = nullptr;
	DI  = nullptr;
	TM  = nullptr;

	select = 0;
	twoPlayer = false;
	selected = false;

	// -1 == INVALID ID
	FontImageID = -1;
	loadScreenID[0] = -1;
	loadScreenID[1] = -1;
	loadScreenID[2] = -1;
	loadScreenID[3] = -1;

	altLoadID = -1;
	buttonA = -1;
	buttonX = -1;
	buttonB = -1;

	// Sound
	menuDelete = -1;
}

LoadGameState::~LoadGameState(void)
{
}

void LoadGameState::Enter() 
{
	D3D	=	CSGD_Direct3D::GetInstance();
	DI	=	CSGD_DirectInput::GetInstance();
	TM	=	CSGD_TextureManager::GetInstance();

	if(CSGD_XAudio2::GetInstance()->MusicIsSongPlaying(Game::GetInstance()->GetMenuMusic()) == false)
		CSGD_XAudio2::GetInstance()->MusicPlaySong(Game::GetInstance()->GetMenuMusic(),true);

	GroupFont =	CBitmapFont::GetInstance();

	FontImageID = TM->LoadTexture(_T("Graphics/Robovox.bmp"), D3DCOLOR_XRGB(0,0,0));
	loadScreenID[0] = TM->LoadTexture(_T("Graphics/Menu Images/loading_menuS1.png"));
	loadScreenID[1] = TM->LoadTexture(_T("Graphics/Menu Images/loading_menuS2.png"));
	loadScreenID[2] = TM->LoadTexture(_T("Graphics/Menu Images/loading_menuS3.png"));
	loadScreenID[3] = TM->LoadTexture(_T("Graphics/Menu Images/loading_menuS4.png"));

	altLoadID = TM->LoadTexture(_T("Graphics/Menu Images/alt_loading_menu.png"));
	buttonA = TM->LoadTexture(_T("Graphics/Menu Images/ButtonA.png"));
	buttonX = TM->LoadTexture(_T("Graphics/Menu Images/ButtonX.png"));
	buttonB = TM->LoadTexture(_T("Graphics/Menu Images/ButtonB.png"));

	GroupFont->SetValues(32, 32, 16, 14, ' ', FontImageID);

	Game::GetInstance()->LoadGame("Slot1.xml",0);
	Game::GetInstance()->LoadGame("Slot2.xml",1);
	Game::GetInstance()->LoadGame("Slot3.xml",2);

	// Sound
	menuDelete = CSGD_XAudio2::GetInstance()->SFXLoadSound(_T("Sound/Menu Sounds/menu_delete.wav"));

	selected = false;
}

void LoadGameState::Exit() 
{
	if(FontImageID != -1)
	{
		TM->UnloadTexture(FontImageID);
		FontImageID = -1;
	}
	for(int i = 0; i < 4; ++i)
	{
		if(loadScreenID[i] != -1)
		{
			TM->UnloadTexture(loadScreenID[i]);
			loadScreenID[i] = -1;
		}
	}
	if(altLoadID != -1)
	{
		TM->UnloadTexture(altLoadID);
		altLoadID = -1;
	}
	if(buttonA != -1)
	{
		TM->UnloadTexture(buttonA);
		buttonA = -1;
	}
	if(buttonX != -1)
	{
		TM->UnloadTexture(buttonX);
		buttonX = -1;
	}
	if(buttonB != -1)
	{
		TM->UnloadTexture(buttonB);
		buttonB = -1;
	}

	// Set data members to 'clean' default values
	D3D = nullptr;
	DI  = nullptr;
	TM  = nullptr;
	GroupFont = nullptr;
}

bool LoadGameState::Input() 
{
	Game* game = Game::GetInstance();

	// If escape return to main menu
	if(DI->JoystickButtonPressed(6) || DI->JoystickButtonPressed(1))
	{
		if(!selected)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuBack());
			Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
			return true;
		}
		else
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuBack());
			selected = false;
			twoPlayer = false;
		}
	}

	if(DI->JoystickGetLStickDirPressed(DIR_RIGHT))
	{
		if(!selected)
		{
			if(select < 2)
				++select;
			else
				select = 0;
			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuMove());
		}
		else
		{
			twoPlayer = !twoPlayer;
			if(saves[select].numPlayers == 0)
				CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuMove());
		}

	}

	if(DI->JoystickGetLStickDirPressed(DIR_LEFT))
	{
		if(!selected)
		{
			if(select > 0)
				--select;
			else
				select = 2;

			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuMove());
		}
		else
		{
			twoPlayer = !twoPlayer;
			if(saves[select].numPlayers == 0)
				CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuMove());
		}
	}

	if(DI->JoystickGetLStickDirPressed(DIR_UP) ||DI->JoystickGetLStickDirPressed(DIR_DOWN))
	{
		if(!selected)
		{
			if(select != 3)
				select = 3;
			else
				select = 0;

			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuMove());
		}
	}

	if(DI->JoystickButtonPressed(0) && selected == false)
	{
		if(!selected && select != 3)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());
			selected = true;
			return true;
		}
		else if(select == 3)
		{
			CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuBack());
			Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
			return true;
		}
	}

	if(selected == true && select != 3)
	{
		switch(select)
		{
			case 0:
			{		
				if(DI->JoystickButtonPressed(0) && saves[0].numPlayers == 0)
				{
					CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

					GamePlayState::GetInstance()->SetMuliplayer(twoPlayer);
					GamePlayState::GetInstance()->SetSaveSlot(1);
					GamePlayState::GetInstance()->SetNewGame(true);////////////////
					Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
					return true;
				}
				else if(saves[0].numPlayers > 0)
				{
					if(DI->JoystickButtonPressed(2))
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(menuDelete);

						Game::GetInstance()->SaveGame(select+1,true);
						Game::GetInstance()->LoadGame("Slot1.xml",select);
						selected = false;
						return true;
					}
					else if(DI->JoystickButtonPressed(0) && saves[0].numPlayers == 1)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(false);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[0].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[0].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[0].numCircuitry);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[0].purchased[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(1);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
					else if(DI->JoystickButtonPressed(0) && saves[0].numPlayers == 2)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(true);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[0].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[0].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[0].numCircuitry);
						GamePlayState::GetInstance()->GetPlayer2()->SetMetal(saves[0].numMetalP2);
						GamePlayState::GetInstance()->GetPlayer2()->SetCircuitry(saves[0].numCircuitryP2);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[0].purchased[i];
						}
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer2()->purchased[i] = saves[0].purchasedP2[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(1);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
				}
			}
			break;

			case 1:
			{
				if(DI->JoystickButtonPressed(0) && saves[1].numPlayers == 0)
				{
					CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

					GamePlayState::GetInstance()->SetMuliplayer(twoPlayer);
					GamePlayState::GetInstance()->SetSaveSlot(2);
					GamePlayState::GetInstance()->SetNewGame(true);
					Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
					return true;
				}
				else if(saves[1].numPlayers > 0)
				{
					if(DI->JoystickButtonPressed(2))
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(menuDelete);
	
						Game::GetInstance()->SaveGame(select+1,true);
						Game::GetInstance()->LoadGame("Slot2.xml",select);
						return true;
					}
					else if(DI->JoystickButtonPressed(0) && saves[1].numPlayers == 1)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(false);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[1].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[1].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[1].numCircuitry);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[1].purchased[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(2);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
					else if(DI->JoystickButtonPressed(0) && saves[1].numPlayers == 2)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(true);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[1].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[1].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[1].numCircuitry);
						GamePlayState::GetInstance()->GetPlayer2()->SetMetal(saves[1].numMetalP2);
						GamePlayState::GetInstance()->GetPlayer2()->SetCircuitry(saves[1].numCircuitryP2);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[1].purchased[i];
						}
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer2()->purchased[i] = saves[1].purchasedP2[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(2);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
				}
			}
			break;

			case 2:
			{
				if(DI->JoystickButtonPressed(0) && saves[2].numPlayers == 0)
				{
					CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

					GamePlayState::GetInstance()->SetMuliplayer(twoPlayer);
					GamePlayState::GetInstance()->SetSaveSlot(3);
					GamePlayState::GetInstance()->SetNewGame(true);
					Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
					return true;
				}
				else if(saves[2].numPlayers > 0)
				{
					if(DI->JoystickButtonPressed(2))
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(menuDelete);

						Game::GetInstance()->SaveGame(select+1,true);
						Game::GetInstance()->LoadGame("Slot3.xml",select);
					}
					else if(DI->JoystickButtonPressed(0) && saves[2].numPlayers == 1)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(false);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[2].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[2].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[2].numCircuitry);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[2].purchased[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(3);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
					else if(DI->JoystickButtonPressed(0) && saves[2].numPlayers == 2)
					{
						CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuSelect());

						GamePlayState::GetInstance()->SetMuliplayer(true);
						GamePlayState::GetInstance()->Enter();
						GamePlayState::GetInstance()->SetCurDungeon(saves[2].numPieces);
						GamePlayState::GetInstance()->GetPlayer()->SetMetal(saves[2].numMetal);
						GamePlayState::GetInstance()->GetPlayer()->SetCircuitry(saves[2].numCircuitry);
						GamePlayState::GetInstance()->GetPlayer2()->SetMetal(saves[2].numMetalP2);
						GamePlayState::GetInstance()->GetPlayer2()->SetCircuitry(saves[2].numCircuitryP2);
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer()->purchased[i] = saves[2].purchased[i];
						}
						for(int i = 0; i < 10; i++)
						{
							GamePlayState::GetInstance()->GetPlayer2()->purchased[i] = saves[2].purchasedP2[i];
						}
						GamePlayState::GetInstance()->SetSaveSlot(3);
						Game::GetInstance()->ChangeState(GamePlayState::GetInstance());
						return true;
					}
				}
			}
			break;
		}
	}

	if(DI->JoystickButtonPressed(1) && selected == true)
	{
		selected = false;
		CSGD_XAudio2::GetInstance()->SFXPlaySound(game->GetMenuBack());
	}

	return true;
}

void LoadGameState::Update(float elapsed) 
{

}

void LoadGameState::Render() 
{
	DWORD isSelected = D3DCOLOR_ARGB(255,255,0,0);
	DWORD notSelected =  D3DCOLOR_ARGB(255,0,255,255);

	if(Game::GetInstance()->GetLanguage() == true)
	{
		TM->Draw(loadScreenID[select],0,0);

		if(selected == false || select == 3)
		{
			TM->Draw(buttonA,480,500,.6f,.6f);
			GroupFont->Print("- Select",520,515,.5f,notSelected);
		}
		if(selected == true && select != 3)
		{
			TM->Draw(buttonA,480,500,.6f,.6f);
			GroupFont->Print("- Play",520,515,.5f,notSelected);

			TM->Draw(buttonB,510,470,.6f,.6f);
			GroupFont->Print("- Deselect",550,485,.5f,notSelected);

		}
		if(selected == true && saves[select].numPlayers > 0 && select != 3)
		{
			TM->Draw(buttonX,450,470,.6f,.6f);
			GroupFont->Print("Delete Save -",300,485,.5f,notSelected);
		}

		// Button A //	460,360
		//CSGD_TextureManager::GetInstance()->Draw(buttonA,80,500,.6f,.6f);
		//char Abutton[25] = " - Purchase";
		//Game::GetInstance()->DrawBitmapFont(Abutton,120,515,.5f,D3DCOLOR_XRGB(255,255,255));
		//// Button Y //
		//CSGD_TextureManager::GetInstance()->Draw(buttonY,80,440,.6f,.6f);
		//char Ybutton[25] = " - Equip Weapon";
		//Game::GetInstance()->DrawBitmapFont(Ybutton,120,455,.5f,D3DCOLOR_XRGB(255,255,255));
		// Button B //
		//CSGD_TextureManager::GetInstance()->Draw(buttonB,110,470,.6f,.6f);
		//char Bbutton[25] = " - Exit";
		//Game::GetInstance()->DrawBitmapFont(Bbutton,150,485,.5f,D3DCOLOR_XRGB(255,255,255));


		// Draw info in save slots

		/* Save Slot 1*/
		if(saves[0].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Empty",110,200,.5f,notSelected);
		}
		else if(saves[0].numPlayers != 0)
		{
			char player[15];
			sprintf_s(player,"Players: %i", saves[0].numPlayers);
			GroupFont->Print(player, 110, 200, 0.5f, notSelected);

			char pieces[20];
			sprintf_s(pieces,"SAVIOR\nPieces: %i", saves[0].numPieces);
			GroupFont->Print(pieces, 110, 230, 0.5f, notSelected);

			char numCircuitry[20];
			sprintf_s(numCircuitry,"\nCircuitry: %i", saves[0].numCircuitry);
			GroupFont->Print(numCircuitry, 110, 260, 0.5f, notSelected);

			char numMetal[20];
			sprintf_s(numMetal,"\nScrap\nMetal: %i", saves[0].numMetal);
			GroupFont->Print(numMetal, 110, 290, 0.5f, notSelected);

			int weapons = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[0].purchased[i] == 1)
					weapons++;
			}

			char numWeapons[25];
			sprintf_s(numWeapons,"\n\nWeapons\nPurchased: %i", weapons);
			GroupFont->Print(numWeapons, 110, 320, 0.5f, notSelected);
		}

		/* Save Slot 2 */
		if(saves[1].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Empty",330,200,.5f,notSelected);
		}
		else if(saves[1].numPlayers != 0)
		{
			char player2[15];
			sprintf_s(player2,"Players: %i", saves[1].numPlayers);
			GroupFont->Print(player2, 330, 200, 0.5f, notSelected);

			char pieces2[20];
			sprintf_s(pieces2,"SAVIOR\nPieces: %i", saves[1].numPieces);
			GroupFont->Print(pieces2, 330, 230, 0.5f, notSelected);

			char numCircuitry2[20];
			sprintf_s(numCircuitry2,"\nCircuitry: %i", saves[1].numCircuitry);
			GroupFont->Print(numCircuitry2, 330, 260, 0.5f, notSelected);

			char numMetal2[20];
			sprintf_s(numMetal2,"\nScrap\nMetal: %i", saves[1].numMetal);
			GroupFont->Print(numMetal2, 330, 290, 0.5f, notSelected);

			int weapons2 = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[1].purchased[i] == 1)
					weapons2++;
			}

			char numWeapons2[25];
			sprintf_s(numWeapons2,"\n\nWeapons\nPurchased: %i", weapons2);
			GroupFont->Print(numWeapons2, 330, 320, 0.5f, notSelected);
		}

		/* Save Slot 3 */
		if(saves[2].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Empty",545,200,.5f,notSelected);
		}
		else if(saves[2].numPlayers != 0)
		{
			char player3[15];
			sprintf_s(player3,"Players: %i", saves[2].numPlayers);
			GroupFont->Print(player3, 545, 200, 0.5f, notSelected);

			char pieces3[20];
			sprintf_s(pieces3,"SAVIOR\nPieces: %i", saves[2].numPieces);
			GroupFont->Print(pieces3, 545, 230, 0.5f, notSelected);

			char numCircuitry3[20];
			sprintf_s(numCircuitry3,"\nCircuitry: %i", saves[2].numCircuitry);
			GroupFont->Print(numCircuitry3, 545, 260, 0.5f, notSelected);

			char numMetal3[20];
			sprintf_s(numMetal3,"\nScrap\nMetal: %i", saves[2].numMetal);
			GroupFont->Print(numMetal3, 545, 290, 0.5f, notSelected);

			int weapons3 = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[2].purchased[i] == 1)
					weapons3++;
			}

			char numWeapons3[25];
			sprintf_s(numWeapons3,"\n\nWeapons\nPurchased: %i", weapons3);
			GroupFont->Print(numWeapons3, 545, 320, 0.5f, notSelected);
		}

		if(selected == true)
		{
			switch(select)
			{
				case 0:
				{
					if(saves[0].numPlayers == 0)
					{
						GroupFont->Print("Players: ", 110, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 240, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;

				case 1:
				{
					if(saves[1].numPlayers == 0)
					{
						GroupFont->Print("Players: ", 330, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 460, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;

				case 2:
				{
					if( saves[2].numPlayers == 0)
					{
						GroupFont->Print("Players: ", 545, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 670, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;
			}
		}
	}
	else
	{
		TM->Draw(altLoadID,0,0);

		// Draw Menu items
		GroupFont->PrintTCHAR(loadStr,	75,  50,  2.5f,	notSelected);

		GroupFont->PrintTCHAR(pro1Str,	120, 150, .75f,	select==0 ? isSelected : notSelected);
		GroupFont->PrintTCHAR(pro2Str,	335, 150, .75f,	select==1 ? isSelected : notSelected);
		GroupFont->PrintTCHAR(pro3Str,	550, 150, .75f,	select==2 ? isSelected : notSelected);
		GroupFont->PrintTCHAR(backStr,	100, 475, 1.0f,	select==3 ? isSelected : notSelected);

		/* Save Slot 1*/
		if(saves[0].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Leeg",110,200,.5f,notSelected);
		}
		else if(saves[0].numPlayers != 0)
		{
			char player[15];
			sprintf_s(player,"Spelers: %i", saves[0].numPlayers);
			GroupFont->Print(player, 110, 200, 0.5f, notSelected);

			char pieces[20];
			sprintf_s(pieces,"SAVIOR\nStukken: %i", saves[0].numPieces);
			GroupFont->Print(pieces, 110, 230, 0.5f, notSelected);

			char numCircuitry[20];
			sprintf_s(numCircuitry,"\nCircuit: %i", saves[0].numCircuitry);
			GroupFont->Print(numCircuitry, 110, 260, 0.5f, notSelected);

			char numMetal[20];
			sprintf_s(numMetal,"\nSchroot: %i", saves[0].numMetal);
			GroupFont->Print(numMetal, 110, 290, 0.5f, notSelected);

			int weapons = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[0].purchased[i] == 1)
					weapons++;
			}

			char numWeapons[25];
			sprintf_s(numWeapons,"\n\nWapens\nGekocht: %i", weapons);
			GroupFont->Print(numWeapons, 110, 320, 0.5f, notSelected);
		}

		/* Save Slot 2 */
		if(saves[1].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Leeg",330,200,.5f,notSelected);
		}
		else if(saves[1].numPlayers != 0)
		{
			char player2[15];
			sprintf_s(player2,"Spelers: %i", saves[1].numPlayers);
			GroupFont->Print(player2, 330, 200, 0.5f, notSelected);

			char pieces2[20];
			sprintf_s(pieces2,"SAVIOR\nStukken: %i", saves[1].numPieces);
			GroupFont->Print(pieces2, 330, 230, 0.5f, notSelected);

			char numCircuitry2[20];
			sprintf_s(numCircuitry2,"\nCircuit: %i", saves[1].numCircuitry);
			GroupFont->Print(numCircuitry2, 330, 260, 0.5f, notSelected);

			char numMetal2[20];
			sprintf_s(numMetal2,"\nSchroot: %i", saves[1].numMetal);
			GroupFont->Print(numMetal2, 330, 290, 0.5f, notSelected);

			int weapons2 = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[1].purchased[i] == 1)
					weapons2++;
			}

			char numWeapons2[25];
			sprintf_s(numWeapons2,"\n\nWapens\nGekocht: %i", weapons2);
			GroupFont->Print(numWeapons2, 330, 320, 0.5f, notSelected);
		}

		/* Save Slot 3 */
		if(saves[2].numPlayers == 0 && selected == false)
		{
			GroupFont->Print("Leeg",545,200,.5f,notSelected);
		}
		else if(saves[2].numPlayers != 0)
		{
			char player3[15];
			sprintf_s(player3,"Spelers: %i", saves[2].numPlayers);
			GroupFont->Print(player3, 545, 200, 0.5f, notSelected);

			char pieces3[20];
			sprintf_s(pieces3,"SAVIOR\nStukken: %i", saves[2].numPieces);
			GroupFont->Print(pieces3, 545, 230, 0.5f, notSelected);

			char numCircuitry3[20];
			sprintf_s(numCircuitry3,"\nCircuit: %i", saves[2].numCircuitry);
			GroupFont->Print(numCircuitry3, 545, 260, 0.5f, notSelected);

			char numMetal3[20];
			sprintf_s(numMetal3,"\nSchroot: %i", saves[2].numMetal);
			GroupFont->Print(numMetal3, 545, 290, 0.5f, notSelected);

			int weapons3 = 0;
			for(int i = 0; i < 10; i++)
			{
				if(saves[2].purchased[i] == 1)
					weapons3++;
			}

			char numWeapons3[25];
			sprintf_s(numWeapons3,"\n\nWapens\nGekocht: %i", weapons3);
			GroupFont->Print(numWeapons3, 545, 320, 0.5f, notSelected);
		}

		if(selected == true)
		{
			switch(select)
			{
				case 0:
				{
					if(saves[0].numPlayers == 0)
					{
						GroupFont->Print("Spelers: ", 110, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 240, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;

				case 1:
				{
					if(saves[1].numPlayers == 0)
					{
						GroupFont->Print("Spelers: ", 330, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 460, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;

				case 2:
				{
					if( saves[2].numPlayers == 0)
					{
						GroupFont->Print("Spelers: ", 545, 200, 0.5f, selected == true ? isSelected : notSelected);
						GroupFont->Print(twoPlayer == false ? "1" : "2", 670, 200, 0.5f, selected == true ? isSelected : notSelected);
					}
				}
				break;
			}
		}
	}



	
}

LoadGameState* LoadGameState::GetInstance()
{
	static LoadGameState instance;
	return &instance;
}
